using System.Collections.Generic;
using System.Data;
using CYZHAPI.Common.DB;
using CYZHAPI.Entity;
using CYZHAPI.IRepository;

namespace CYZHAPI.Repository
{
    public class CantonRep : ReponsitoryBase<CantonModel>, ICantonRep
    {
        public CantonRep(IDapperContext dbContext) : base(dbContext)
        {
        }

        public List<CantonModel> GetList(string sWhere)
        {
            List<CantonModel> reList = new List<CantonModel> ();
            DataSet ds = base.GetList ("AREACODE", sWhere);
            
            if (ds != null && ds.Tables[0].Rows.Count > 0) {
                foreach (DataRow dr in ds.Tables[0].Rows) {
                    CantonModel objBean = new CantonModel () {
                        code = dr["CODE"].ToString (),
                        name = dr["NAME"].ToString ()//,
                        //jb = dr["jb"].ToString ()
                    };
                    reList.Add (objBean);
                    //foreach (DataColumn dc in ds.Tables[0].Columns) {}
                }
            } else {
                return null;
            }

            return reList;
        }
    }
}